package com.hksj.sftcm.controller;

import com.hksj.base.query.AlarmQuery;
import com.hksj.base.query.BaseSpecialityQuery;
import com.hksj.common.core.model.Rest;
import com.hksj.sftcm.query.SftcmDailyAlarmQuery;
import com.hksj.sftcm.query.SpecialityProductQuery;
import com.hksj.sftcm.service.SftcmService;
import com.hksj.sftcm.vo.AlarmOverviewVO;
import com.hksj.sftcm.vo.SftcmDayAlarmNumVO;
import com.hksj.sftcm.vo.SftcmProductAlarmVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "专用设施温度-接口")
@RestController
@RequestMapping("/api/sftcm")
public class SftcmController {
    @Autowired
    private SftcmService sftcmService;

    @ApiOperation("大屏-当前报警设备分布")
    @PostMapping("/getAlarmOverview")
    public Rest<AlarmOverviewVO> getAlarmOverview(@RequestBody AlarmQuery query){
        AlarmOverviewVO res = sftcmService.getAlarmOverview(query);
        return Rest.ok(res);
    }

    @ApiOperation("大屏-最近7天报警次数趋势")
    @PostMapping("/listAlarmChartData")
    public Rest<List<SftcmProductAlarmVO>> listAlarmChartData(@RequestBody SftcmDailyAlarmQuery query){
        List<SftcmProductAlarmVO> list = sftcmService.listAlarmChartData(query);
        return Rest.ok(list);
    }

    @ApiOperation("报警记录-导出")
    @PostMapping("/exportAlarm")
    public void exportAlarm(@RequestBody AlarmQuery query, HttpServletResponse response){
        sftcmService.exportAlarm(query,response);
    }
}
